package com.zw.mes.module.prdctionFlow.service;


import com.zw.mes.entity.flow.FlowRoute;
import com.zw.mes.entity.flow.FlowTrans;
import com.zw.mes.module.prdctionFlow.mapper.HistAppiyMapper;
import com.zw.mes.module.prdctionFlow.model.HistAppiyModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@SuppressWarnings("all")
public class HistAppiyService {
    @Autowired
    private HistAppiyMapper histAppiyMapper;

    /**
     * 历史申请列表
     * @return
     */
    public List<HistAppiyModel> findHistList(HistAppiyModel histAppiyModel) {
        return histAppiyMapper.findfHistList(histAppiyModel);
    }

    /**
     * 待质检数据撤销更新状态与路线表数据
     * @param id
     * @return
     */
    public Integer updateFlowCheck(Integer id) {
        int applyNum;
        FlowTrans flowTrans = histAppiyMapper.findFlowTrans(id);
        flowTrans.setStatus(2);
        histAppiyMapper.updateFlowTransStatus(flowTrans);
        FlowRoute flowRoute = histAppiyMapper.findSelFlowroute(flowTrans.getRouteId());
        applyNum = flowRoute.getApplyNum() - flowTrans.getNum();
        flowRoute.setApplyNum(applyNum);
        return histAppiyMapper.updateFlowRuoteApp(flowRoute);
    }
}

